from common.base.base_handler import BaseHandler
from .model import Telemetry
from .schemas.dsp_telemetry import DspTelemetry
from .schemas.gps_telemetry import GpsTelemetry
from .schemas.pwr_telemetry import PwrTelemetry
from .schemas.sfp_telemetry import SfpTelemetry
from settings import settings


class TelemetryHandler(BaseHandler):
    __slots__ = ['model']

    async def handle_get_gps_telemetry(self) -> GpsTelemetry:
        return self.model.gps_telemetry

    async def handle_get_dsp_telemetry(self) -> DspTelemetry:
        return self.model.dsp_telemetry

    async def handle_get_pwr_telemetry(self) -> PwrTelemetry:
        pwr = self.model.pwr_telemetry
        return self.model.pwr_telemetry

    async def handle_get_sfp_telemetry(self) -> SfpTelemetry:
        return self.model.sfp_telemetry

    async def handle_get_numSV_telemetry(self) -> int:
        return self.model.numSV


    def __init__(self):
        self.model = Telemetry()

        super(TelemetryHandler, self).__init__(request_queue_uuid=settings.TELEMETRY_REQUEST_QUEUE)

        self.handle('get_gps_telemetry', self.handle_get_gps_telemetry)
        self.handle('get_dsp_telemetry', self.handle_get_dsp_telemetry)
        self.handle('get_pwr_telemetry', self.handle_get_pwr_telemetry)
        self.handle('get_sfp_telemetry', self.handle_get_sfp_telemetry)
        self.handle('get_numSV_telemetry', self.handle_get_numSV_telemetry)
